import { Tag, Card } from "antd";
import React from "react";
import ResourceApprove from "./ResourceApprove";
import { useArticleReview } from "../../Layout/Review/useArticleReview";
import { useActivityReview } from "../../Layout/Review/useActivityReview";
import { useLawdocReview } from "../../Layout/Review/useLawdocReview";
import { useExpertReview } from "../../Layout/Review/useExpertReview";
import { useBeforeApproveActivityApply } from "./useBeforeApproveActivityApply";
import { useActivityApplyReview } from "../../Layout/Review/useActivityApplyReview";

const topStyle = { marginTop: 15 };

const articleColumns = [
    {
        title: '标题',
        dataIndex: 'title',
        key: 'title',
    },
    {
        title: '内容分类',
        dataIndex: 'categoryTitle',
        key: 'categoryTitle',
        width: 120
    },{
        title: "是否头条",
        dataIndex: "isHot",
        width: 60,
        render: (isHot: number) => {
            return (<>
                { isHot === 1 && <Tag color="error">是</Tag> }
                { isHot === 0 && <Tag color="green">否</Tag> }
            </>);
        }
    },{
        title: '创建用户',
        dataIndex: 'createUserName',
        key: 'createUserName',
        width: 120,
    },{
        title: "更新时间",
        dataIndex: "updateDateTime",
        width: 160
    }
];

const lawDocColumns = [
    {
        title: "发布主体",
        dataIndex: "publishOwner",
        width: 80
    }, {
        title: "分类",
        dataIndex: "categoryTitle",
        width: 100
    },
    {
        title: "标题",
        dataIndex: "title"
    }, {
        title: '创建用户',
        dataIndex: 'createUserName',
        key: 'createUserName',
        width: 120,
    },{
        title: "更新时间",
        dataIndex: "updateDateTime",
        width: 160
    }
];


const activityColumns = [
    {
        title: "活动标题",
        dataIndex: "title",
    }, {
        title: "主办单位",
        dataIndex: "hostOrganization",
        width: 160
    },
    {
        title: "城市地区",
        dataIndex: "region",
        width: 200
    }, {
        title: '创建用户',
        dataIndex: 'createUserName',
        key: 'createUserName',
        width: 120,
    },{
        title: "创建时间",
        dataIndex: "createDateTime",
        width: 160
    }
];

const expertColumns = [
    {
        title: "专家分类",
        dataIndex: "categoryTitle",
        width: 100
    },{
        title: "姓名",
        dataIndex: "name",
        width: 100
    }, {
        title: "性别",
        dataIndex: "gender",
        width: 60,
        render: (v: string) => {
            return v === "male" ? '男' : '女'
        }
    },{
        title: "工作单位",
        dataIndex: "company"
    }, {
        title: "岗位职称",
        dataIndex: "ocupation",
    },{
        title: '创建用户',
        dataIndex: 'createUserName',
        key: 'createUserName',
        width: 120,
    },{
        title: "更新时间",
        dataIndex: "updateDateTime",
        width: 160
    }
];
const activityApply = [{
        title: "单位名称",
        dataIndex: "hostOrganization",
        width: 80
    }, {
        title: "活动目的",
        dataIndex: "activityPurpose",
        width: 160,
        render: (info: string) => {
            const infoList = info?.length > 0 ? JSON.parse(info) : [];
            return (<>
                {
                    infoList.map((item: any) => {
                        return <Tag key={item} color={"geekblue"}>{item}</Tag>;
                    })
                }
            </>);
        }
    },
    {
        title: "活动需求",
        dataIndex: "requirement",
    },{
        title: "服务时段",
        dataIndex: "activityPeriod",
        width: 100
    },{
        title: "联系人",
        dataIndex: "contactor",
        width: 100
    }, {
        title: "联系电话",
        dataIndex: "mobile",
        width: 100
    },{
        title: '创建用户',
        dataIndex: 'createUserName',
        key: 'createUserName',
        width: 120,
    },{
        title: "更新时间",
        dataIndex: "updateDateTime",
        width: 160
    }];
const ResourceApproveSections = () => {
    const reviewArticle = useArticleReview();
    const reviewActivity = useActivityReview();
    const reviewLawdoc = useLawdocReview();
    const expertReview = useExpertReview();
    const reviewActivityApply = useActivityApplyReview();
    const onApproveApply = useBeforeApproveActivityApply();
    return <div>
        <ResourceApprove
            columns={articleColumns}
            listEndPoint="article.approveList"
            submitEndPoint="article.approveSubmit"
            title="待审批科普资源"
            style={topStyle}
            onReview={({ id}) => reviewArticle.show(id)}
        />
        <ResourceApprove
            columns={lawDocColumns}
            listEndPoint="lawdoc.approveList"
            submitEndPoint="lawdoc.approveSubmit"
            title="待审批政策法规"
            style={topStyle}
            onReview={({ id}) => reviewLawdoc.show(id)}
        />
        <ResourceApprove
            columns={activityApply}
            listEndPoint="activity.approveApplyList"
            submitEndPoint="activity.applyStatus"
            cancelEndPoint="activity.applyWithdraw"
            title="待审批活动申请"
            style={topStyle}
            approveText="通过"
            onBeforeApprove={onApproveApply}
            onReview={({ id}) => reviewActivityApply.show(id)}
        />
        <ResourceApprove
            columns={activityColumns}
            listEndPoint="activity.approveList"
            submitEndPoint="activity.approveSubmit"
            cancelEndPoint="activity.updateStatus"
            title="待审批科普活动"
            style={topStyle}
            cancelStatus={-3}
            onReview={({ id}) => reviewActivity.show(id)}
        />
         <ResourceApprove
            columns={expertColumns}
            listEndPoint="resource.expertApproveList"
            submitEndPoint="resource.expertApproveSubmit"
            title="待审批科普专家"
            style={topStyle}
            onReview={({ id}) => expertReview.show(id)}
        />
        {reviewArticle.Provider}
        {reviewActivity.Provider}
        {reviewLawdoc.Provider}
        {expertReview.Provider}
        {reviewActivityApply.Provider}
    </div>;
};

export default ResourceApproveSections;
